package com.taru.order.service;



import com.taru.order.dao.ArtDaoImpl;
import com.taru.order.entity.Articl;
import com.taru.order.entity.ArticlLikes;
import com.taru.order.entity.Colletion;

import java.io.IOException;
import java.util.List;

public class ArtServiceImpl {

    ArtDaoImpl artDao=new ArtDaoImpl();


    /**
     * 添加文章
     * @param articl
     * @return
     * @throws IOException
     */
    public int addArticl(Articl articl) throws IOException {

        return  artDao.addArticl(articl);
    }
    /**
     * 根据articl_id获取获取文章详情
     */
    public Articl getArticlById(String id) {

        return  artDao.getArticlById(id);
    }
    /**
     * 批量删除文章（先要删除该文章的所有图片）(也可以是文章删除，图片跟着消失)
     */
    public int removeArticls(List list) throws Exception {

        return artDao.removeArticls(list);
    }
    /**
     * 修改文章内容（包括图片路径）
     */
    public int modArticl(Articl articl) throws  IOException{

        return artDao.modArticl(articl);
    }
    /**
     * 修改文章状态
     */
    public int modArticlStatus(Articl articl){

        return artDao.modArticlStatus(articl);
    }
    /**
     * 修改文章的logo
     */
    public  int modArticlLogo(Articl articl){

        return artDao.modArticlLogo(articl);
    }
    /**
     * 增加点赞数
     */
    public int inArticlLikes(ArticlLikes like) {
        int code=artDao.addArticlLikes(like);
        return code;
    }
    /**
     * 减少点赞数
     */
    public int outArticlLikes(ArticlLikes like)  {
        int code=artDao.deleteArticlLikes(like);
        return code;
    }
    /**
     * 判断有没有被点赞过
     */
    public boolean queryArticlLikes(ArticlLikes like){
        ArticlLikes likes=artDao.queryArticlLikes(like);
        boolean isExist=false;
        if(likes!=null){
            isExist=true;
        }
        return isExist;
    }
    /**
     * 给文章添加专题
     */
    public int addArtGroup(Articl articl){

        return artDao.addArtGroup(articl);
    }
    /**
     * 根据时间查询文章列表
     */
    public List<Articl> getArticlByYearMonth(String year,String month){

        return artDao.getArticlByYearMonth(year,month);
    }
    /**
     * 查询连载文章
     */
    public List<Articl>  getArticlNoEnd(){

        return artDao.getArticlNoEnd();
    }
    /**
     * 查询已完结文章
     */
    public List<Articl>  getArticlEnd(){

        return artDao.getArticlEnd();
    }
    /**
     * 判断文章有没有被收藏
     */
    public boolean queryArticlCollection(Colletion colletion){
        Colletion colletion1=artDao.queryArticlCollection(colletion);
        boolean isExist=false;
        if(colletion1 !=null){
            isExist=true;
        }
        System.out.println(isExist);
        return isExist;
    }
}
